var mongoose=require('mongoose');
var Schema=mongoose.Schema;
var config=require('../config');
var Province=require('./province')
var db=mongoose.createConnection(config.db_url);
db.on('error',function(error){
    console.log(error);
});

db.model('Province',Province.provinceSchema);
var citySchema=new Schema({
    name:String,
    province:{type:Schema.Types.ObjectId,ref:'Province'}
});
//users---对应数据库表名
var City=db.model('City',citySchema);

/**
 * 获得简介信息
 */

City.prototype.findCityByPid=function(pid,callback){
    City.find({province:pid},function(err,datas){
        callback(err,datas);
    })
}

City.prototype.updateCity=function(options,callback){
    City.update({},options,function(err){
        callback(err)
    });
}

module.exports =City;
module.exports.citySchema=citySchema;

